<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.zust.java.bean.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- <script language="javascript" type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script> -->
<title>创建订单</title>
<script type="text/javascript">
    function check(field) {
    	with(field) {
    		var rx = new RegExp("[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|2[0-9]|3[0-1])");
    		if (deadline.value == null || deadline.value == "") {
    		        alert("截至日期不能为空");
    		        return false;
    		  }
    		if (!rx.test(deadline.value)) {
    			alert("格式不正确");
    			return false;
    		}
    		return true;
    	}
    }
    
</script>
</head>
<body>
<% 
    Date date = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    List<OrderDetail> list = (List<OrderDetail>) request.getSession().getAttribute("orderDetailList");
%>
<!--  <%= ((Account)request.getSession().getAttribute("account")).getId() %> -->
    
            订单号:&nbsp;<input name="orderNo" disabled="disabled" type="text" style="width:100px" value="<%= request.getSession().getAttribute("currentValue") %>" ><br>
            当前日期:<input name="creatTime" type="text" style="width:100px" disabled="disable" value="<%= dateFormat.format(date) %>"><br>
    <form action="updateOrder" method="post" onsubmit="return check(this)">     
            截至日期:<input name="deadline" type="text" style="width:100px" placeholder="格式:2017-05-19"><br>
        <input name="submit" type="submit"  value="生成订单">
    </form>
     <button name="delete" onclick="window.location.href='deleteOrder?orderNo=<%= request.getSession().getAttribute("currentValue") %>'">取消订单</button>
     <button name="choose" onclick="window.location.href='showProduct?orderNo=<%= request.getSession().getAttribute("currentValue") %>'">增加商品</button>
    <br>
    <%
        if (list != null && !list.contains(null) && !list.isEmpty()) {
    %>
    <table border="1px">
        <tr>
            <th>名称</th>
            <th>数量</th>
            <th>操作</th>
        </tr>    
        <%
            for (OrderDetail o : list) {
        %>
        <tr>
            <td><%= o.getName() %></td>
            <td><%= o.getNumber() %></td>
            <td>
                <button name="delete" onclick="window.location.href='delete?name=<%=o.getName()%>&orderNo=<%= request.getSession().getAttribute("currentValue") %>'">删除</button>
            </td>
        </tr>
        <% } %>
    </table>
    <% } %>
</body>
</html>